//
//  TSGuideViewController.m
//  Park
//
//  Created by Seven on 15/12/3.
//  Copyright © 2015年 Toocms. All rights reserved.
//

#import "TSGuideViewController.h"

#import "AppDelegate.h"
#import "TSTabbarController.h"

@interface TSGuideViewController ()<UIScrollViewDelegate>
@property(nonatomic,strong)UIScrollView * scrollView;
@property(nonatomic,strong)UIPageControl *pageC;
@end

@implementation TSGuideViewController



- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self _initView];
}

#pragma mark - 初始化UI

/** 初始化View*/
- (void)_initView {
    int n = 3;  //设置引导图数量
    
    _scrollView = [UIScrollView scrollViewWithBgColor:nil frame:Rect(0, 0, kScreenWidth, kScreenHeigth)];
    
    _scrollView.contentSize = Size(kScreenWidth * n, 0);
    _scrollView.showsVerticalScrollIndicator = NO;
    _scrollView.showsHorizontalScrollIndicator = NO;
    _scrollView.bounces = NO;
    _scrollView.pagingEnabled = YES;
    _scrollView.delegate = self;
    [self.view addSubview:_scrollView];
    

    for (int i = 0; i < n; i++) {
        NSString * name = [NSString stringWithFormat:@"new_feature_%d",i + 1];
        UIImageView * imageView = [UIImageView imageViewWithImage:[UIImage imageNamed:name] frame:Rect(kScreenWidth * i, 0, kScreenWidth, kScreenHeigth)];
        imageView.userInteractionEnabled = YES;
        [_scrollView addSubview:imageView];
        if (i == n - 1) {
            [imageView addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap)]];
        }
    }

}
- (void)tap {

    [[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"First"];
    [[NSUserDefaults standardUserDefaults] synchronize];
        //切换根视图
    AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate; // 获取当前app单例
    app.window.rootViewController =[[TSNavigationController
                                      alloc]initWithRootViewController: [TSTabbarController new]];

}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{

    self.pageC.currentPage = self.scrollView.contentOffset.x / kScreenWidth;
}

#pragma mark - Action


#pragma mark - 网络请求


#pragma mark - Delegate

#pragma mark - Private


#pragma mark - 懒加载



@end
